<template>
	<view class="waikuang">
		<view class="renwbaot">我的{{curMonth}}月任务</view>
		<view class="renwuxx">
			<view class="renwumc">平台推广</view>
			<view class="wcxijie">
				<view>任务要求:{{allData.tgrw}}人</view>
				<view>已完成{{allData.wctg}}人</view>
				<view>完成率:{{allData.wctg/allData.tgrw*100}}%</view>
			</view>
		</view>
		<view class="renwuxx">
			<view class="renwumc">理发任务</view>
			<view class="wcxijie">
				<view>任务要求:{{allData.lfrw}}人</view>
				<view>已完成:{{allData.wclf}}人</view>
				<view>完成率:{{allData.wclf/allData.lfrw}}%</view>
			</view>
		</view>
		<view class="renwuxx">
			<view class="renwumc">店面打扫</view>
			<view class="wcxijie">
				<view>任务要求:{{allData.wsrw}}次</view>
				<view>已完成:{{allData.wcws}}次</view>
				<view>完成率:{{allData.wcws/allData.wsrw}}%</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				yg_id:'',
				user:null,
				sex:'',
				name:'',
				touxiang:'',
				dqjs:'',
				mendian_id:'',
				allData:{},
				curMonth:''
			}
		},
		onLoad() {
		var that = this;
		uni.getStorage({
			key: 'user_key',
			complete: function(res) {
				// console.log(666,res)
				that.yg_id = res.data.id;
				that.user = res.data;
				that.sex = res.data.sex;
				that.name = res.data.name;
				that.touxiang = res.data.touxiang;
				that.dqjs = res.data.role;
				that.mendian_id = res.data.mendian;
				that.getTaskData();
			}
		})
		},
		methods: {
			//获取员工我的任务数据
			getTaskData(){
				let _that = this;
				const date = new Date();
				let year = date.getFullYear();
				let month = date.getMonth() + 1;
				let dateNew = `${year}-${month}`;
				_that.curMonth=dateNew.substring(5,7)
				// console.log(111,_that.curMonth)
				uni.request({
					url: getApp().globalData.url + '/client/GetUsrenw',
					method: 'GET',
					data: {
						id: _that.yg_id,
						yuef:dateNew
					},
					header: {
						"Content-Type": "application/json"
					},
					success: function(res) {
						console.log(555,res)
						if (res.data.code == 200 && res.data.msg == '查询成功') {
						_that.allData=res.data.data;	
						} else {
							uni.showToast({
								icon: 'none',
								position: 'center',
								title: "请求出现异常！"
							});
						}
					}
				})
			}
		},
	}
</script>

<style lang="scss" scoped>
	.waikuang{
		width: 710rpx;
		padding: 20rpx;
		.renwuxx{
			margin-top: 20rpx;
			font-size: 26rpx;
			color: #3F536E;
			border-bottom: solid 1rpx #e1e1e1;
			padding-bottom: 20rpx;
			.renwumc{
				color: #555555;
				font-weight: bold;
			}
			.wcxijie{
				display: flex;
				justify-content: space-between;
				align-items: center;
				margin-top: 10rpx;
			}
		}
		.renwbaot{
			font-size: 35rpx;
			font-weight: bold;
		}
	}
</style>
